package com.smart.parking.controller.backstage;

import java.util.Arrays;
import java.util.Map;

import com.smart.parking.config.Result;
import com.smart.parking.entity.RepairEntity;
import com.smart.parking.service.RepairService;
import com.smart.parking.service.SpaceService;
import com.smart.parking.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 车位维修表
 *
 * @author ciyun
 */
@RestController
@RequestMapping("/repair")
public class RepairController {
    @Autowired
    private RepairService repairService;

    @Autowired
    private SpaceService spaceService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Result list(@RequestParam Map<String, Object> params) {
        PageUtils page = repairService.queryPage(params);

        return Result.ok().put("page", page);
    }


    /**
     * 更新维修状态
     *
     * @param repairID 修复id
     * @param state    状态
     * @return {@link Result}
     */
    @GetMapping("/updateRepair")
    public Result updateRepair(@RequestParam("repairID") Long repairID, @RequestParam("state") Integer state) {
        spaceService.updateRepair(repairID, state);
        return Result.ok();
    }

}
